/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package model;

import java.util.List;
import constants.*;
import java.text.SimpleDateFormat;
import javax.swing.table.AbstractTableModel;
/**
 *
 * @author Tuan Minh
 */
public class InfoBookingModel extends AbstractTableModel {
    List<entity.InfoBooking> list ;
    public InfoBookingModel(List<entity.InfoBooking> list){
        this.list=list;
    }
    public final static String[] columnNames = {
        "STT","Mã khách hàng","Họ tên","Ngày đặt ","Ngày nhận","Ngày trả","Số phòng","Đã thanh toán ","Tổng thanh toán"
    };
    public int getRowCount() {
        return list.size();
    }
    public int getColumnCount() {
        return columnNames.length;
    }
 
    public Object getValueAt(int row, int col) {
           //Widget widget = (Widget) list.get(row);
        switch(col){
            case 0: return row+1;
            case 1: return list.get(row).getId_customer();               
            case 2: return list.get(row).getCustomer().getName();
            case 3: return list.get(row).getDate();
            case 4: return list.get(row).getCheckin();
            case 5: return list.get(row).getCheckout();
            case 6: return list.get(row).getNumber_room();
            case 7: return list.get(row).getPayment();
            case 8: return list.get(row).getTotal();                
            default: return null;  
            }
    }
 
    // Need for showing column name
    @Override
    public String getColumnName(int columnIndex) {
        return columnNames[columnIndex];
    }
    public void refesh(){
        fireTableDataChanged();
    }
    public void removeRow(int row) {
        list.remove(row);
        fireTableDataChanged();
    }
    public void insertList(entity.InfoBooking e){
        list.add(e);
        fireTableDataChanged();       
    }
    public void editList(int index,entity.InfoBooking e){
         list.remove(index);
         list.add(index, e);
         fireTableDataChanged();    
    }
}
